package com.example.video.video_server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.video.video_server.entity.VideoInfo;
import com.example.video.video_server.service.IHotVideoCountService;
import com.example.video.video_server.service.IVideoInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HotVideoCountServiceImpl implements IHotVideoCountService {

    @Autowired
    private IVideoInfoService iVideoInfoService;


    @Override
    public List getHotList(Integer categoryParentId) {
        List<VideoInfo> list = iVideoInfoService.list(new QueryWrapper<>(new VideoInfo()
                                                                            .setCategoryParentId(categoryParentId).setIsRelease("0"))
                                                                            .orderByDesc("play_count").last("limit 0 , 24"));
        return list;
    }
}
